//
//  AIFFailPayManager.m
//  PywSdk
//
//  Created by apple on 16/1/26.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "AIFFailPayManager.h"

@implementation AIFFailPayManager

NSString *const FailPay_Sign = @"sign";
NSString *const FailPay_UserName = @"username";
NSString *const FailPay_Orderno = @"orderno";
NSString *const FailPay_Passport_Token = @"passport_token";
NSString *const FailPay_Token = @"token";
NSString *const FailPay_GameId = @"gameid";
NSString *const FailPay_Tid = @"tid";

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.child = self;
        self.paramSource = self;
        self.validate = self;
    }
    return self;
}


#pragma mark - ETAPIManager
- (NSString *)methodName{
    return URL_PAY_FAIL;
}

- (ETAPIManagerRequestType)requestType{
    return ETAPIManagerRequestTypePost;
}


- (NSString *)seriviceType{
    return [PywAppInfo sharedAppInfo].seriviceType;
}


#pragma mark - ETAPIManagerParamSourceDelegate
- (NSDictionary *)paramsForApi:(ETApiBaseManager *)manager{
    NSString *tid = [PywAppInfo sharedAppInfo].tid;
    NSString *orderno = self.orderno;
    NSString * apiSeret2 = [AppUtil getApiSecret2:tid apiSecret:[PywAppInfo sharedAppInfo].apisecret];
    NSString * gameid = [PywAppInfo sharedAppInfo].gameId;
    NSString * userName = [PywPlatformMain sharedPlatformMain].userName;
    NSString * sign = [PywCipherUtils md5:[NSString stringWithFormat:@"%@%@%@", orderno ,userName,apiSeret2]];
    
    MutableDictionary *param = [[MutableDictionary alloc] init];
    
    if ([PywPlatformMain sharedPlatformMain].accountType == UserType_Passport) {
        NSString *passport_token = [PywPlatformMain sharedPlatformMain].passport_Token;
        [param setObject:passport_token forKey:FailPay_Passport_Token];
    }else if ([PywPlatformMain sharedPlatformMain].accountType ==  UserType_Account){
        NSString *token = [PywPlatformMain sharedPlatformMain].token;
        [param setObject:token forKey:FailPay_Token];
    }
    
    [param setObject:tid forKey:FailPay_Tid];
    [param setObject:orderno forKey:FailPay_Orderno];
    [param setObject:gameid forKey:FailPay_GameId];
    [param setObject:sign forKey:FailPay_Sign];
    [param setObject:userName forKey:FailPay_UserName];
    return param;
}



#pragma mark - ETAPIManagerValidator
- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithParamsData:(NSDictionary *)data{
    if (data[FailPay_Orderno] == nil) {
        return NO;
        PLog(@"=============订单号不能为空==============");
    }
    return YES;
}

- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithCallBackData:(NSDictionary *)data{
    return YES;
}


@end
